package ihm.tool;

import java.util.Random;

/**
 * Outils pour manipuler des chaines de caractères.
 * @author Guillaume Poças & Jean-François Augé
 */
public class StringUtils {

	public static String generateRandomString(int length) {
        String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; 
        StringBuffer pass = new StringBuffer();
        for(int x=0;x<length;x++)   {
           int i = (int)Math.floor(Math.random() * (chars.length() -1));
           pass.append(chars.charAt(i));
        }
        return pass.toString();
	}
	
	public static String generateRandomString2(int length) {
		Random rng = new Random();
		byte[] tab = new byte[length];
		rng.setSeed(System.currentTimeMillis());
		rng.nextBytes(tab);
		Integer.valueOf(System.getProperty("user.name"));
        return tab.toString();
	}
	
	public static void main(String[] args) {
		
	}

}
